URL='http://localhost:8601/';
var tmap="null";
var new_element=document.createElement("script");
new_element.setAttribute("type","text/javascript");
new_element.setAttribute("src","js/jquery.min.js");
document.body.appendChild(new_element);
login = function () {
    var loginname = $("#loginname").val();
    var loginpasword = $("#loginpasword").val();
    $.ajax({
        url: URL + 'login',
        method: 'post',
        data: {user_username: loginname, user_password: loginpasword},
        dataType: "json",
//        crossDomain: true,
        xhrFields: {
            withCredentials: true
        },
        success: function (data) {
            console.log(data);
            if (data.loginUser != null && data.loginUser != '') {
                localStorage.setExpire("user",data.loginUser.user,1800000);
                localStorage.setExpire("token",data.loginUser.token,1800000);
                //window.localStorage.setItem("token",data.loginUser.token);
                //window.localStorage.setItem("user",JSON.stringify(data.loginUser.user));
                var user=window.localStorage.getItem("user");
                console.log(JSON.parse(user));
                window.location.href = "../adview/index.html";
            } else {
                alert(data.msg);
            }
        }
    })
 /*       ajax.onreadystatechange =function(){
        //alert("服务器请求的状态："+ajax.readyState);
        //alert("服务器响应的状态："+ajax.status);
        if(ajax.readyState==4 && ajax.status==200){
            //5.接收服务器的数据
            //varcurTime = ajax.responseText;

            //网页局部刷新
            //document.getElementById("time").innerHTML = curTime;
        }
    })*/
}